<?php

class FeatureHistory extends AppModel
{
	var $name = "FeatureHistory";
	Const ACTIVE = 1;
	Const ARCHIVED = 2;
	function addToActive($entity,$id)
	{
		$this->create();
		$data[$this->alias] = array('entity'=>$entity,'entity_id'=>$id,'status'=>self::ACTIVE);
		$this->save($data);
	}
	
	function addToArchive($entity,$id)
	{
		$featureId = $this->field('id',array('entity'=>$entity,'entity_id'=>$id,'status'=>self::ACTIVE));
		if($featureId)
		{
			$this->id = $featureId;
			$data[$this->alias] = array('status' => self::ARCHIVED,"archived_date"=>date('Y-m-d'));
			$this->save($data);
		}
	}
}